/*
** Made by texane <texane@gmail.com>
** 
** Started on  Sun Jan  6 20:16:12 2008 texane
** Last update Wed Jan  9 00:28:30 2008 texane
*/



#ifndef BST_H_INCLDUED
# define BST_H_INCLDUED



typedef struct bst_node
{
  struct bst_node* next;
  struct bst_node* prev;

  struct bst_node* parent;
  struct bst_node* left;
  struct bst_node* right;

  void* data;
} bst_node_t;


void bst_node_init(bst_node_t*);
void bst_node_release(bst_node_t*);



typedef struct bst_tree
{
  bst_node_t* root;
  bst_node_t* first;
} bst_tree_t;


void bst_tree_init(bst_tree_t*);
void bst_tree_release(bst_tree_t*, void (*)(bst_node_t*));
void bst_tree_insert_node(bst_tree_t*, bst_node_t*, int(*)(void*, void*));
void bst_tree_remove_node(bst_tree_t*, bst_node_t*);
int bst_tree_find_node(bst_tree_t*, int (*)(void*, void*), void*, bst_node_t**);
void bst_tree_foreach_node(bst_tree_t*, void (*)(void*, void*), void*);



#endif /* ! BST_H_INCLDUED */
